package lily.phs.child;


import lily.phs.object.TwoChild;
import lily.phs.urh.R;
import lily.ui.control.MyPopupWindow;



import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.InputType;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

public class OneToTwoChildView_Two extends RelativeLayout implements OnFocusChangeListener,OnClickListener{
	View v;
	Paint paint;
	private LinearLayout ll1;
	MyPopupWindow mPopupWindow;
	private int profileid;
	private Context myContext;
	//ScrollView sv;
	private RadioButton rb_butai_no_2,rb_butai_no_3,rb_butai_no_4,
						rb_butai_yes_2,rb_butai_yes_3,rb_butai_yes_4,
						rb_o_1,rb_o_2,rb_o_3,rb_x_1,rb_x_2,rb_x_3,
						rb_fypg_pass_1,rb_fypg_pass_2,rb_fypg_pass_3,
						rb_fypg_nopass_1,rb_fypg_nopass_2,rb_fypg_nopass_3,
						rb_disease_no_1,rb_disease_no_2,rb_disease_no_3,rb_disease_no_4,
						rb_disease_yes_1,rb_disease_yes_2,rb_disease_yes_3,rb_disease_yes_4,
						rb_zz_no_1,rb_zz_no_2,rb_zz_no_3,rb_zz_no_4,
						rb_zz_yes_1,rb_zz_yes_2,rb_zz_yes_3,rb_zz_yes_4;
	private EditText et_xhdb_2,et_xhdb_4,
					 et_hwhd_1,et_hwhd_2,et_hwhd_3,et_hwhd_4,
					 et_vd_1,et_vd_2,et_vd_3,
					 et_other_1,et_other_2,et_other_3,et_other_4,
					 et_reason_1,et_reason_2,et_reason_3,et_reason_4,
					 et_inst_1,et_inst_2,et_inst_3,et_inst_4,
					 et_guide_1,et_guide_2,et_guide_3,et_guide_4,
					 et_nextdate_1,et_nextdate_2,et_nextdate_3,et_nextdate_4,
					 et_doctor_1,et_doctor_2,et_doctor_3,et_doctor_4,et;
	
	private CheckBox cb_1_1,cb_1_2,cb_1_3,cb_1_4,
					 cb_2_1,cb_2_2,cb_2_3,cb_2_4,
					 cb_3_1,cb_3_2,cb_3_3,cb_3_4,
					 cb_4_1,cb_4_2,cb_4_3,cb_4_4,
					 cb_5_1,cb_5_2,cb_5_3,cb_5_4;
	
	private RadioGroup rg_butai_2,rg_butai_3,rg_butai_4,
					   rg_ox_1,rg_ox_2,rg_ox_3,
					   rg_fypg_1,rg_fypg_2,rg_fypg_3,
					   rg_disease_1,rg_disease_2,rg_disease_3,rg_disease_4,
					   rg_zz_1, rg_zz_2, rg_zz_3, rg_zz_4;
	
	TwoChild tc1,tc2,tc3,tc4;
	
	public OneToTwoChildView_Two(Context context,int pro) {
		super(context);
		myContext=context;
		this.profileid=pro;
		paint=new Paint();
		paint.setStyle(Paint.Style.STROKE);
        paint.setColor(Color.BLACK);
        this.setBackgroundColor(Color.WHITE);
	}
	
	public void findWeight(){
		LayoutInflater factory = LayoutInflater.from(myContext);
        v = factory.inflate(R.layout.onetotwo_child_2, null);
        et=(EditText)v.findViewById(R.id.et_sc_xhdb_dffd2);
        et.setInputType(InputType.TYPE_NULL);
        ll1=(LinearLayout)v.findViewById(R.id.ll);
		//sv=(ScrollView)v.findViewById(R.id.ScrollView01);
        rg_butai_2=(RadioGroup)v.findViewById(R.id.rg_tc_butai_2);
        rg_butai_3=(RadioGroup)v.findViewById(R.id.rg_tc_butai_3);
        rg_butai_4=(RadioGroup)v.findViewById(R.id.rg_tc_butai_4);
        rb_butai_no_2=(RadioButton)v.findViewById(R.id.rb_tc_butai_no_2);
        rb_butai_no_3=(RadioButton)v.findViewById(R.id.rb_tc_butai_no_3);
        rb_butai_no_4=(RadioButton)v.findViewById(R.id.rb_tc_butai_no_4);
        rb_butai_yes_2=(RadioButton)v.findViewById(R.id.rb_tc_butai_yes_2);
        rb_butai_yes_3=(RadioButton)v.findViewById(R.id.rb_tc_butai_yes_3);
        rb_butai_yes_4=(RadioButton)v.findViewById(R.id.rb_tc_butai_yes_4);
        rg_ox_1=(RadioGroup)v.findViewById(R.id.rg_tc_ox_1);
        rg_ox_2=(RadioGroup)v.findViewById(R.id.rg_tc_ox_2);
        rg_ox_3=(RadioGroup)v.findViewById(R.id.rg_tc_ox_3);
        rb_o_1=(RadioButton)v.findViewById(R.id.rb_tc_o_1);
        rb_o_1.requestFocus();
        rb_o_2=(RadioButton)v.findViewById(R.id.rb_tc_o_2);
        rb_o_3=(RadioButton)v.findViewById(R.id.rb_tc_o_3);
        rb_x_1=(RadioButton)v.findViewById(R.id.rb_tc_x_1);
        rb_x_2=(RadioButton)v.findViewById(R.id.rb_tc_x_2);
        rb_x_3=(RadioButton)v.findViewById(R.id.rb_tc_x_3);
		et_xhdb_2=(EditText)v.findViewById(R.id.et_tc_xhdb_2);
		et_xhdb_4=(EditText)v.findViewById(R.id.et_tc_xhdb_4);
		et_hwhd_1=(EditText)v.findViewById(R.id.et_tc_hwhd_1);
		et_hwhd_2=(EditText)v.findViewById(R.id.et_tc_hwhd_2);
		et_hwhd_3=(EditText)v.findViewById(R.id.et_tc_hwhd_3);
		et_hwhd_4=(EditText)v.findViewById(R.id.et_tc_hwhd_4);
		et_vd_1=(EditText)v.findViewById(R.id.et_tc_vd_1);
		et_vd_2=(EditText)v.findViewById(R.id.et_tc_vd_2);
		et_vd_3=(EditText)v.findViewById(R.id.et_tc_vd_3);
		rg_fypg_1=(RadioGroup)v.findViewById(R.id.rg_tc_fypg_1);
		rg_fypg_2=(RadioGroup)v.findViewById(R.id.rg_tc_fypg_2);
		rg_fypg_3=(RadioGroup)v.findViewById(R.id.rg_tc_fypg_3);
		rb_fypg_pass_1=(RadioButton)v.findViewById(R.id.rb_tc_fypg_pass_1);
		rb_fypg_pass_2=(RadioButton)v.findViewById(R.id.rb_tc_fypg_pass_2);
		rb_fypg_pass_3=(RadioButton)v.findViewById(R.id.rb_tc_fypg_pass_3);
		rb_fypg_nopass_1=(RadioButton)v.findViewById(R.id.rb_tc_fypg_nopass_1);
		rb_fypg_nopass_2=(RadioButton)v.findViewById(R.id.rb_tc_fypg_nopass_2);
		rb_fypg_nopass_3=(RadioButton)v.findViewById(R.id.rb_tc_fypg_nopass_3);
		rg_disease_1=(RadioGroup)v.findViewById(R.id.rg_tc_disease_1);
		rg_disease_2=(RadioGroup)v.findViewById(R.id.rg_tc_disease_2);
		rg_disease_3=(RadioGroup)v.findViewById(R.id.rg_tc_disease_3);
		rg_disease_4=(RadioGroup)v.findViewById(R.id.rg_tc_disease_4);
		rb_disease_no_1=(RadioButton)v.findViewById(R.id.rb_tc_disease_no_1);
		rb_disease_no_2=(RadioButton)v.findViewById(R.id.rb_tc_disease_no_2);
		rb_disease_no_3=(RadioButton)v.findViewById(R.id.rb_tc_disease_no_3);
		rb_disease_no_4=(RadioButton)v.findViewById(R.id.rb_tc_disease_no_4);
		rb_disease_yes_1=(RadioButton)v.findViewById(R.id.rb_tc_disease_yes_1);
		rb_disease_yes_2=(RadioButton)v.findViewById(R.id.rb_tc_disease_yes_2);
		rb_disease_yes_3=(RadioButton)v.findViewById(R.id.rb_tc_disease_yes_3);
		rb_disease_yes_4=(RadioButton)v.findViewById(R.id.rb_tc_disease_yes_4);
		et_other_1=(EditText)v.findViewById(R.id.et_tc_other_1);
		et_other_2=(EditText)v.findViewById(R.id.et_tc_other_2);
		et_other_3=(EditText)v.findViewById(R.id.et_tc_other_3);
		et_other_4=(EditText)v.findViewById(R.id.et_tc_other_4);
		rg_zz_1=(RadioGroup)v.findViewById(R.id.rg_tc_zz_1);
		rg_zz_2=(RadioGroup)v.findViewById(R.id.rg_tc_zz_2);
		rg_zz_3=(RadioGroup)v.findViewById(R.id.rg_tc_zz_3);
		rg_zz_4=(RadioGroup)v.findViewById(R.id.rg_tc_zz_4);
		rb_zz_no_1=(RadioButton)v.findViewById(R.id.rb_tc_zz_no_1);
		rb_zz_no_2=(RadioButton)v.findViewById(R.id.rb_tc_zz_no_2);
		rb_zz_no_3=(RadioButton)v.findViewById(R.id.rb_tc_zz_no_3);
		rb_zz_no_4=(RadioButton)v.findViewById(R.id.rb_tc_zz_no_4);
		rb_zz_yes_1=(RadioButton)v.findViewById(R.id.rb_tc_zz_yes_1);
		rb_zz_yes_2=(RadioButton)v.findViewById(R.id.rb_tc_zz_yes_2);
		rb_zz_yes_3=(RadioButton)v.findViewById(R.id.rb_tc_zz_yes_3);
		rb_zz_yes_4=(RadioButton)v.findViewById(R.id.rb_tc_zz_yes_4);
		et_reason_1=(EditText)v.findViewById(R.id.et_tc_zz_reason_1);
		et_reason_2=(EditText)v.findViewById(R.id.et_tc_zz_reason_2);
		et_reason_3=(EditText)v.findViewById(R.id.et_tc_zz_reason_3);
		et_reason_4=(EditText)v.findViewById(R.id.et_tc_zz_reason_4);
		et_inst_1=(EditText)v.findViewById(R.id.et_tc_zz_inst_1);
		et_inst_2=(EditText)v.findViewById(R.id.et_tc_zz_inst_2);
		et_inst_3=(EditText)v.findViewById(R.id.et_tc_zz_inst_3);
		et_inst_4=(EditText)v.findViewById(R.id.et_tc_zz_inst_4);
		cb_1_1=(CheckBox)v.findViewById(R.id.cb_tc_guide_1_1);
		cb_1_2=(CheckBox)v.findViewById(R.id.cb_tc_guide_1_2);
		cb_1_3=(CheckBox)v.findViewById(R.id.cb_tc_guide_1_3);
		cb_1_4=(CheckBox)v.findViewById(R.id.cb_tc_guide_1_4);
		cb_2_1=(CheckBox)v.findViewById(R.id.cb_tc_guide_2_1);
		cb_2_2=(CheckBox)v.findViewById(R.id.cb_tc_guide_2_2);
		cb_2_3=(CheckBox)v.findViewById(R.id.cb_tc_guide_2_3);
		cb_2_4=(CheckBox)v.findViewById(R.id.cb_tc_guide_2_4);
		cb_3_1=(CheckBox)v.findViewById(R.id.cb_tc_guide_3_1);
		cb_3_2=(CheckBox)v.findViewById(R.id.cb_tc_guide_3_2);
		cb_3_3=(CheckBox)v.findViewById(R.id.cb_tc_guide_3_3);
		cb_3_4=(CheckBox)v.findViewById(R.id.cb_tc_guide_3_4);
		cb_4_1=(CheckBox)v.findViewById(R.id.cb_tc_guide_4_1);
		cb_4_2=(CheckBox)v.findViewById(R.id.cb_tc_guide_4_2);
		cb_4_3=(CheckBox)v.findViewById(R.id.cb_tc_guide_4_3);
		cb_4_4=(CheckBox)v.findViewById(R.id.cb_tc_guide_4_4);
		cb_5_1=(CheckBox)v.findViewById(R.id.cb_tc_guide_5_1);
		cb_5_2=(CheckBox)v.findViewById(R.id.cb_tc_guide_5_2);
		cb_5_3=(CheckBox)v.findViewById(R.id.cb_tc_guide_5_3);
		cb_5_4=(CheckBox)v.findViewById(R.id.cb_tc_guide_5_4);
		et_guide_1=(EditText)v.findViewById(R.id.et_tc_guide_1);
		et_guide_2=(EditText)v.findViewById(R.id.et_tc_guide_2);
		et_guide_3=(EditText)v.findViewById(R.id.et_tc_guide_3);
		et_guide_4=(EditText)v.findViewById(R.id.et_tc_guide_4);
		et_nextdate_1=(EditText)v.findViewById(R.id.et_tc_nextdate_1);
		et_nextdate_2=(EditText)v.findViewById(R.id.et_tc_nextdate_2);
		et_nextdate_3=(EditText)v.findViewById(R.id.et_tc_nextdate_3);
		et_nextdate_4=(EditText)v.findViewById(R.id.et_tc_nextdate_4);
		et_nextdate_1.setInputType(InputType.TYPE_NULL);
		et_nextdate_2.setInputType(InputType.TYPE_NULL);
		et_nextdate_3.setInputType(InputType.TYPE_NULL);
		et_nextdate_4.setInputType(InputType.TYPE_NULL);
		et_nextdate_1.setOnClickListener(this);
		et_nextdate_1.setOnFocusChangeListener(this);
		et_nextdate_2.setOnClickListener(this);
		et_nextdate_2.setOnFocusChangeListener(this);
		et_nextdate_3.setOnClickListener(this);
		et_nextdate_3.setOnFocusChangeListener(this);
		et_nextdate_4.setOnClickListener(this);
		et_nextdate_4.setOnFocusChangeListener(this);
		et_doctor_1=(EditText)v.findViewById(R.id.et_tc_doctor_1);
		et_doctor_2=(EditText)v.findViewById(R.id.et_tc_doctor_2);
		et_doctor_3=(EditText)v.findViewById(R.id.et_tc_doctor_3);
		et_doctor_4=(EditText)v.findViewById(R.id.et_tc_doctor_4);
		/*LayoutParams lp=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		this.addView(v,lp);
		
		MyView mv=new MyView(myContext);
		this.addView(mv,lp);*/
		tc1=new TwoChild(myContext);
		tc1.selectTwoChild(profileid, 1);
		tc2=new TwoChild(myContext);
		tc2.selectTwoChild(profileid, 2);
		tc3=new TwoChild(myContext);
		tc3.selectTwoChild(profileid, 3);
		tc4=new TwoChild(myContext);
		tc4.selectTwoChild(profileid, 4);
	}
	
	public void selectData(){
		tc1.selectTwoChild(profileid, 1);
		tc2.selectTwoChild(profileid, 2);
		tc3.selectTwoChild(profileid, 3);
		tc4.selectTwoChild(profileid, 4);
	}
	
	public void addToView(){
		LayoutParams lp=new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		this.addView(v,lp);
		
		MyView mv=new MyView(myContext);
		this.addView(mv,lp);
	}
	
	public void initView(){
		//TwoChild tc=new TwoChild(myContext);
		//tc.selectTwoChild(profileid, 1);
		if(tc1.getTwch_stoop_sign()>0){
			switch(tc1.getTwch_stoop_sign()){
			case 1:
				rg_ox_1.check(0);
				rb_o_1.setChecked(true);
				break;
			case 2:
				rg_ox_1.check(1);
				rb_x_1.setChecked(true);
			}
		}
		if(tc1.getTwch_activity()>0){
			et_hwhd_1.setText(tc1.getTwch_activity()+"");
		}
		if(tc1.getTwch_vd()>0){
			et_vd_1.setText(tc1.getTwch_vd()+"");
		}
		if(tc1.getTwch_deve_asse()>0){
			switch(tc1.getTwch_deve_asse()){
			case 1:
				rg_fypg_1.check(0);
				rb_fypg_pass_1.setChecked(true);
				break;
			case 2:
				rg_fypg_1.check(1);
				rb_fypg_nopass_1.setChecked(true);
				break;
			}
		}
		if(tc1.getTwch_deases()>0){
			switch(tc1.getTwch_deases()){
			case 1:
				rg_disease_1.check(0);
				rb_disease_no_1.setChecked(true);
				break;
			case 2:
				rg_disease_1.check(1);
				rb_disease_yes_1.setChecked(true);
				break;
			}
		}
		et_other_1.setText(tc1.getTwch_other());
		if(tc1.getTwch_refe_choi()>0){
			switch(tc1.getTwch_refe_choi()){
			case 1:
				rg_zz_1.check(0);
				rb_zz_no_1.setChecked(true);
				break;
			case 2:
				rg_zz_1.check(1);
				rb_zz_yes_1.setChecked(true);
				et_reason_1.setText(tc1.getTwch_refe_reasion());
				et_inst_1.setText(tc1.getTwch_refe_inst());
				break;
			}
		}
		if(tc1.getTwch_guide()!=null&&tc1.getTwch_guide().length()>0){
			String s[]=tc1.getTwch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_1.setChecked(true);
					break;
				case 2:
					cb_2_1.setChecked(true);
					break;
				case 3:
					cb_3_1.setChecked(true);
					break;
				case 4:
					cb_4_1.setChecked(true);
					break;
				case 5:
					cb_5_1.setChecked(true);
					break;
				}
			}
		}
		et_guide_1.setText(tc1.getTwch_guide_des());
		et_nextdate_1.setText(tc1.getTwch_next_date());
		et_doctor_1.setText(tc1.getTwch_doctor());
		//20
		tc2.selectTwoChild(profileid, 2);
		if(tc2.getTwch_gait()>0){
			switch(tc2.getTwch_gait()){
			case 1:
				rg_butai_2.check(0);
				rb_butai_no_2.setChecked(true);
				break;
			case 2:
				rg_butai_2.check(1);
				rb_butai_yes_2.setChecked(true);
				break;
			}
		}
		if(tc2.getTwch_stoop_sign()>0){
			switch(tc2.getTwch_stoop_sign()){
			case 1:
				rg_ox_2.check(0);
				rb_o_2.setChecked(true);
				break;
			case 2:
				rg_ox_2.check(1);
				rb_x_2.setChecked(true);
			}
		}
		if(tc2.getTwch_sanguine()>0){
			et_xhdb_2.setText(tc2.getTwch_sanguine()+"");
		}
		if(tc2.getTwch_activity()>0){
			et_hwhd_2.setText(tc2.getTwch_activity()+"");
		}
		if(tc2.getTwch_vd()>0){
			et_vd_2.setText(tc2.getTwch_vd()+"");
		}
		if(tc2.getTwch_deve_asse()>0){
			switch(tc2.getTwch_deve_asse()){
			case 1:
				rg_fypg_2.check(0);
				rb_fypg_pass_2.setChecked(true);
				break;
			case 2:
				rg_fypg_2.check(1);
				rb_fypg_nopass_2.setChecked(true);
				break;
			}
		}
		if(tc2.getTwch_deases()>0){
			switch(tc2.getTwch_deases()){
			case 1:
				rg_disease_2.check(0);
				rb_disease_no_2.setChecked(true);
				break;
			case 2:
				rg_disease_2.check(1);
				rb_disease_yes_2.setChecked(true);
				break;
			}
		}
		et_other_2.setText(tc2.getTwch_other());
		if(tc2.getTwch_refe_choi()>0){
			switch(tc2.getTwch_refe_choi()){
			case 1:
				rg_zz_2.check(0);
				rb_zz_no_2.setChecked(true);
				break;
			case 2:
				rg_zz_2.check(1);
				rb_zz_yes_2.setChecked(true);
				et_reason_2.setText(tc2.getTwch_refe_reasion());
				et_inst_2.setText(tc2.getTwch_refe_inst());
				break;
			}
		}
		if(tc2.getTwch_guide()!=null&&tc2.getTwch_guide().length()>0){
			String s[]=tc2.getTwch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_2.setChecked(true);
					break;
				case 2:
					cb_2_2.setChecked(true);
					break;
				case 3:
					cb_3_2.setChecked(true);
					break;
				case 4:
					cb_4_2.setChecked(true);
					break;
				case 5:
					cb_5_2.setChecked(true);
					break;
				}
			}
		}
		et_guide_2.setText(tc2.getTwch_guide_des());
		et_nextdate_2.setText(tc2.getTwch_next_date());
		et_doctor_2.setText(tc2.getTwch_doctor());
		//24
		tc3.selectTwoChild(profileid, 3);
		if(tc3.getTwch_gait()>0){
			switch(tc3.getTwch_gait()){
			case 1:
				rg_butai_3.check(0);
				rb_butai_no_3.setChecked(true);
				break;
			case 2:
				rg_butai_3.check(1);
				rb_butai_yes_3.setChecked(true);
				break;
			}
		}
		if(tc3.getTwch_stoop_sign()>0){
			switch(tc3.getTwch_stoop_sign()){
			case 1:
				rg_ox_3.check(0);
				rb_o_3.setChecked(true);
				break;
			case 2:
				rg_ox_3.check(1);
				rb_x_3.setChecked(true);
			}
		}
		if(tc3.getTwch_activity()>0){
			et_hwhd_3.setText(tc3.getTwch_activity()+"");
		}
		if(tc3.getTwch_vd()>0){
			et_vd_3.setText(tc3.getTwch_vd()+"");
		}
		if(tc3.getTwch_deve_asse()>0){
			switch(tc3.getTwch_deve_asse()){
			case 1:
				rg_fypg_3.check(0);
				rb_fypg_pass_3.setChecked(true);
				break;
			case 2:
				rg_fypg_3.check(1);
				rb_fypg_nopass_3.setChecked(true);
				break;
			}
		}
		if(tc3.getTwch_deases()>0){
			switch(tc3.getTwch_deases()){
			case 1:
				rg_disease_3.check(0);
				rb_disease_no_3.setChecked(true);
				break;
			case 2:
				rg_disease_3.check(1);
				rb_disease_yes_3.setChecked(true);
				break;
			}
		}
		et_other_3.setText(tc3.getTwch_other());
		if(tc3.getTwch_refe_choi()>0){
			switch(tc3.getTwch_refe_choi()){
			case 1:
				rg_zz_3.check(0);
				rb_zz_no_3.setChecked(true);
				break;
			case 2:
				rg_zz_3.check(1);
				rb_zz_yes_3.setChecked(true);
				et_reason_3.setText(tc3.getTwch_refe_reasion());
				et_inst_3.setText(tc3.getTwch_refe_inst());
				break;
			}
		}
		if(tc3.getTwch_guide()!=null&&tc3.getTwch_guide().length()>0){
			String s[]=tc3.getTwch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_3.setChecked(true);
					break;
				case 2:
					cb_2_3.setChecked(true);
					break;
				case 3:
					cb_3_3.setChecked(true);
					break;
				case 4:
					cb_4_3.setChecked(true);
					break;
				case 5:
					cb_5_3.setChecked(true);
					break;
				}
			}
		}
		et_guide_3.setText(tc3.getTwch_guide_des());
		et_nextdate_3.setText(tc3.getTwch_next_date());
		et_doctor_3.setText(tc3.getTwch_doctor());
		//30
		tc4.selectTwoChild(profileid, 4);
		if(tc4.getTwch_gait()>0){
			switch(tc4.getTwch_gait()){
			case 1:
				rg_butai_4.check(0);
				rb_butai_no_4.setChecked(true);
				break;
			case 2:
				rg_butai_4.check(1);
				rb_butai_yes_4.setChecked(true);
				break;
			}
		}
		if(tc4.getTwch_sanguine()>0){
			et_xhdb_4.setText(tc4.getTwch_sanguine()+"");
		}
		if(tc4.getTwch_activity()>0){
			et_hwhd_4.setText(tc4.getTwch_activity()+"");
		}
		if(tc4.getTwch_deases()>0){
			switch(tc4.getTwch_deases()){
			case 1:
				rg_disease_4.check(0);
				rb_disease_no_4.setChecked(true);
				break;
			case 2:
				rg_disease_4.check(1);
				rb_disease_yes_4.setChecked(true);
				break;
			}
		}
		et_other_4.setText(tc4.getTwch_other());
		if(tc4.getTwch_refe_choi()>0){
			switch(tc4.getTwch_refe_choi()){
			case 1:
				rg_zz_4.check(0);
				rb_zz_no_4.setChecked(true);
				break;
			case 2:
				rg_zz_4.check(1);
				rb_zz_yes_4.setChecked(true);
				et_reason_4.setText(tc4.getTwch_refe_reasion());
				et_inst_4.setText(tc4.getTwch_refe_inst());
				break;
			}
		}
		if(tc4.getTwch_guide()!=null&&tc4.getTwch_guide().length()>0){
			String s[]=tc4.getTwch_guide().split(",");
			for(int i=0;i<s.length;i++){
				switch(Integer.parseInt(s[i])){
				case 1:
					cb_1_4.setChecked(true);
					break;
				case 2:
					cb_2_4.setChecked(true);
					break;
				case 3:
					cb_3_4.setChecked(true);
					break;
				case 4:
					cb_4_4.setChecked(true);
					break;
				case 5:
					cb_5_4.setChecked(true);
					break;
				}
			}
		}
		et_guide_4.setText(tc4.getTwch_guide_des());
		et_nextdate_4.setText(tc4.getTwch_next_date());
		et_doctor_4.setText(tc4.getTwch_doctor());
		//
	}
	
	public boolean saveView(){
		if(et_xhdb_2.getText().toString().replaceAll("\\s", "").length()>10||
				et_xhdb_2.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_xhdb_2.setError("数据长度超过范围");
			return false;
		}
		if(et_xhdb_4.getText().toString().replaceAll("\\s", "").length()>10||
				et_xhdb_4.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_xhdb_4.setError("数据长度超过范围");
			return false;
		}
		if(et_hwhd_1.getText().toString().replaceAll("\\s", "").length()>10||
				et_hwhd_1.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_hwhd_1.setError("数据长度超过范围");
			return false;
		}
		if(et_hwhd_2.getText().toString().replaceAll("\\s", "").length()>10||
				et_hwhd_2.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_hwhd_2.setError("数据长度超过范围");
			return false;
		}
		if(et_hwhd_3.getText().toString().replaceAll("\\s", "").length()>10||
				et_hwhd_3.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_hwhd_3.setError("数据长度超过范围");
			return false;
		}
		if(et_hwhd_4.getText().toString().replaceAll("\\s", "").length()>10||
				et_hwhd_4.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_hwhd_4.setError("数据长度超过范围");
			return false;
		}
		if(et_vd_1.getText().toString().replaceAll("\\s", "").length()>10||
				et_vd_1.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_vd_1.setError("数据长度超过范围");
			return false;
		}
		if(et_vd_2.getText().toString().replaceAll("\\s", "").length()>10||
				et_vd_2.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_vd_2.setError("数据长度超过范围");
			return false;
		}
		if(et_vd_3.getText().toString().replaceAll("\\s", "").length()>10||
				et_vd_3.getText().toString().replaceAll("\\s", "").startsWith("-")){
			et_vd_3.setError("数据长度超过范围");
			return false;
		}
		TwoChild tc=new TwoChild(myContext);
		tc.selectTwoChild(profileid, 1);
		if(rb_o_1.isChecked()){
			tc.setTwch_stoop_sign(1);
		}
		else if(rb_x_1.isChecked()){
			tc.setTwch_stoop_sign(2);
		}
		if(et_hwhd_1.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_activity(Float.parseFloat(et_hwhd_1.getText().toString().replaceAll("\\s", "")));
		}
		if(et_vd_1.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_vd(Float.parseFloat(et_vd_1.getText().toString().replaceAll("\\s", "")));
		}
		if(rb_fypg_pass_1.isChecked()){
			tc.setTwch_deve_asse(1);
		}
		else if(rb_fypg_nopass_1.isChecked()){
			tc.setTwch_deve_asse(2);
		}
		if(rb_disease_no_1.isChecked()){
			tc.setTwch_deases(1);
		}
		else if(rb_disease_yes_1.isChecked()){
			tc.setTwch_deases(2);
		}
		tc.setTwch_other(et_other_1.getText().toString().replaceAll("\\s", ""));
		if(rb_zz_no_1.isChecked()){
			tc.setTwch_refe_choi(1);
		}
		else if(rb_zz_yes_1.isChecked()){
			tc.setTwch_refe_choi(2);
			tc.setTwch_refe_reasion(et_reason_1.getText().toString().replaceAll("\\s", ""));
			tc.setTwch_refe_inst(et_inst_1.getText().toString().replaceAll("\\s", ""));
		}
		String str="";
		if(cb_1_1.isChecked()){
			str+="1,";
		}
		if(cb_2_1.isChecked()){
			str+="2,";
		}
		if(cb_3_1.isChecked()){
			str+="3,";
		}
		if(cb_4_1.isChecked()){
			str+="4,";
		}
		if(cb_5_1.isChecked()){
			str+="5";
		}
		tc.setTwch_guide(str);
		tc.setTwch_guide_des(et_guide_1.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_next_date(et_nextdate_1.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_doctor(et_doctor_1.getText().toString().replaceAll("\\s", ""));
		tc.updateTwoChild(profileid, 1);
		//20
		tc.selectTwoChild(profileid, 2);
		if(rb_butai_no_2.isChecked()){
			tc.setTwch_gait(1);
		}
		else if(rb_butai_yes_2.isChecked()){
			tc.setTwch_gait(2);
		}
		if(rb_o_2.isChecked()){
			tc.setTwch_stoop_sign(1);
		}
		else if(rb_x_2.isChecked()){
			tc.setTwch_stoop_sign(2);
		}
		if(et_xhdb_2.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_sanguine(Float.parseFloat(et_xhdb_2.getText().toString().replaceAll("\\s", "")));
		}
		if(et_hwhd_2.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_activity(Float.parseFloat(et_hwhd_2.getText().toString().replaceAll("\\s", "")));
		}
		if(et_vd_2.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_vd(Float.parseFloat(et_vd_2.getText().toString().replaceAll("\\s", "")));
		}
		if(rb_fypg_pass_2.isChecked()){
			tc.setTwch_deve_asse(1);
		}
		else if(rb_fypg_nopass_2.isChecked()){
			tc.setTwch_deve_asse(2);
		}
		if(rb_disease_no_2.isChecked()){
			tc.setTwch_deases(1);
		}
		else if(rb_disease_yes_2.isChecked()){
			tc.setTwch_deases(2);
		}
		tc.setTwch_other(et_other_2.getText().toString().replaceAll("\\s", ""));
		if(rb_zz_no_2.isChecked()){
			tc.setTwch_refe_choi(1);
		}
		else if(rb_zz_yes_2.isChecked()){
			tc.setTwch_refe_choi(2);
			tc.setTwch_refe_reasion(et_reason_2.getText().toString().replaceAll("\\s", ""));
			tc.setTwch_refe_inst(et_inst_2.getText().toString().replaceAll("\\s", ""));
		}
		str="";
		if(cb_1_2.isChecked()){
			str+="1,";
		}
		if(cb_2_2.isChecked()){
			str+="2,";
		}
		if(cb_3_2.isChecked()){
			str+="3,";
		}
		if(cb_4_2.isChecked()){
			str+="4,";
		}
		if(cb_5_2.isChecked()){
			str+="5";
		}
		tc.setTwch_guide(str);
		tc.setTwch_guide_des(et_guide_2.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_next_date(et_nextdate_2.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_doctor(et_doctor_2.getText().toString().replaceAll("\\s", ""));
		tc.updateTwoChild(profileid, 2);
		//24
		tc.selectTwoChild(profileid, 3);
		if(rb_butai_no_3.isChecked()){
			tc.setTwch_gait(1);
		}
		else if(rb_butai_yes_3.isChecked()){
			tc.setTwch_gait(2);
		}
		if(rb_o_3.isChecked()){
			tc.setTwch_stoop_sign(1);
		}
		else if(rb_x_3.isChecked()){
			tc.setTwch_stoop_sign(2);
		}
		if(et_hwhd_3.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_activity(Float.parseFloat(et_hwhd_3.getText().toString().replaceAll("\\s", "")));
		}
		if(et_vd_3.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_vd(Float.parseFloat(et_vd_3.getText().toString().replaceAll("\\s", "")));
		}
		if(rb_fypg_pass_3.isChecked()){
			tc.setTwch_deve_asse(1);
		}
		else if(rb_fypg_nopass_3.isChecked()){
			tc.setTwch_deve_asse(2);
		}
		if(rb_disease_no_3.isChecked()){
			tc.setTwch_deases(1);
		}
		else if(rb_disease_yes_3.isChecked()){
			tc.setTwch_deases(2);
		}
		tc.setTwch_other(et_other_3.getText().toString().replaceAll("\\s", ""));
		if(rb_zz_no_3.isChecked()){
			tc.setTwch_refe_choi(1);
		}
		else if(rb_zz_yes_3.isChecked()){
			tc.setTwch_refe_choi(2);
			tc.setTwch_refe_reasion(et_reason_3.getText().toString().replaceAll("\\s", ""));
			tc.setTwch_refe_inst(et_inst_3.getText().toString().replaceAll("\\s", ""));
		}
		str="";
		if(cb_1_3.isChecked()){
			str+="1,";
		}
		if(cb_2_3.isChecked()){
			str+="2,";
		}
		if(cb_3_3.isChecked()){
			str+="3,";
		}
		if(cb_4_3.isChecked()){
			str+="4,";
		}
		if(cb_5_3.isChecked()){
			str+="5";
		}
		tc.setTwch_guide(str);
		tc.setTwch_guide_des(et_guide_3.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_next_date(et_nextdate_3.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_doctor(et_doctor_3.getText().toString().replaceAll("\\s", ""));
		tc.updateTwoChild(profileid, 3);
		//30
		tc.selectTwoChild(profileid, 4);
		if(rb_butai_no_4.isChecked()){
			tc.setTwch_gait(1);
		}
		else if(rb_butai_yes_4.isChecked()){
			tc.setTwch_gait(2);
		}
		if(et_xhdb_4.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_sanguine(Float.parseFloat(et_xhdb_4.getText().toString().replaceAll("\\s", "")));
		}
		if(et_hwhd_4.getText().toString().replaceAll("\\s", "").length()>0){
			tc.setTwch_activity(Float.parseFloat(et_hwhd_4.getText().toString().replaceAll("\\s", "")));
		}
		if(rb_disease_no_4.isChecked()){
			tc.setTwch_deases(1);
		}
		else if(rb_disease_yes_4.isChecked()){
			tc.setTwch_deases(2);
		}
		tc.setTwch_other(et_other_4.getText().toString().replaceAll("\\s", ""));
		if(rb_zz_no_4.isChecked()){
			tc.setTwch_refe_choi(1);
		}
		else if(rb_zz_yes_4.isChecked()){
			tc.setTwch_refe_choi(2);
			tc.setTwch_refe_reasion(et_reason_4.getText().toString().replaceAll("\\s", ""));
			tc.setTwch_refe_inst(et_inst_4.getText().toString().replaceAll("\\s", ""));
		}
		str="";
		if(cb_1_4.isChecked()){
			str+="1,";
		}
		if(cb_2_4.isChecked()){
			str+="2,";
		}
		if(cb_3_4.isChecked()){
			str+="3,";
		}
		if(cb_4_4.isChecked()){
			str+="4,";
		}
		if(cb_5_4.isChecked()){
			str+="5";
		}
		tc.setTwch_guide(str);
		tc.setTwch_guide_des(et_guide_4.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_next_date(et_nextdate_4.getText().toString().replaceAll("\\s", ""));
		tc.setTwch_doctor(et_doctor_4.getText().toString().replaceAll("\\s", ""));
		tc.updateTwoChild(profileid, 4);
		
		return true;
	}
	
	class MyView extends View {
    	//View v;
    	Paint paint;
    	
		public MyView(Context context) {
			super(context);
			paint=new Paint();
			paint.setStyle(Paint.Style.STROKE);
            paint.setColor(Color.BLACK);
		}
		
		@Override
		public void onDraw(Canvas c){
	        int top=ll1.getTop();
	        int left=ll1.getLeft()-15;
	        int right=ll1.getRight()+15;
	        int bottom=ll1.getBottom();
	        int y=0;//sv.getScrollY();
	        int height=rb_butai_no_2.getHeight();
	        int height2=et_xhdb_2.getHeight();
	        top=top-y-40;
	        bottom=bottom-y;
	        
	        c.drawLine(left, top+122, right, top+122, paint);
	        c.drawLine(left+35, top+122+40+height, right, top+122+40+height, paint);
	        c.drawLine(left+35, top+152+40*2+height*2, right, top+152+40*2+height*2, paint);
	        c.drawLine(left, top+152+40*3+height*2+height2, right, top+152+40*3+height*2+height2, paint);
	        c.drawLine(left, top+152+40*4+height*2+height2*2, right, top+152+40*4+height*2+height2*2, paint);
	        c.drawLine(left, top+152+40*5+height*2+height2*3, right, top+152+40*5+height*2+height2*3, paint);
	        c.drawLine(left, top+152+40*6+height*3+height2*3, right, top+152+40*6+height*3+height2*3, paint);
	        c.drawLine(left, top+152+40*7+height*5+height2*3, right, top+152+40*7+height*5+height2*3, paint);
	        c.drawLine(left, top+152+40*8+height*5+height2*4, right, top+152+40*8+height*5+height2*4, paint);
	        c.drawLine(left, top+160+40*9+height*7+height2*6, right, top+160+40*9+height*7+height2*6, paint);
	        c.drawLine(left, top+180+40*10+height*12+height2*7, right, top+180+40*10+height*12+height2*7, paint);
	        c.drawLine(left, top+180+40*11+height*12+height2*8, right, top+180+40*11+height*12+height2*8, paint);
	        c.drawLine(left, top+180+40*12+height*12+height2*9, right, top+180+40*12+height*12+height2*9, paint);
	        
	        c.drawLine(left, top+122, left, top+180+40*12+height*12+height2*9, paint);
	        c.drawLine(right, top+122, right, top+180+40*12+height*12+height2*9, paint);
	        
	        c.drawLine(left+115, top+122, left+115, top+180+40*12+height*12+height2*9, paint);
	        c.drawLine(left+275, top+122, left+275, top+180+40*12+height*12+height2*9, paint);
	        c.drawLine(left+435, top+122, left+435, top+180+40*12+height*12+height2*9, paint);
	        c.drawLine(left+595, top+122, left+595, top+180+40*12+height*12+height2*9, paint);
	        
	        c.drawLine(left+35, top+122, left+35, top+152+40*3+height*2+height2, paint);
	        	        
		}
    	
    }

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if(v==et_nextdate_1){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_1), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_1.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_2){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_2), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_2.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_3){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_3), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_3.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_4){
			mPopupWindow = new MyPopupWindow(myContext);			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_4), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_4.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
	}

	@Override
	public void onFocusChange(View v, boolean hasFocus) {
		// TODO Auto-generated method stub
		if(v==et_nextdate_1&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_1  ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_1.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_2&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_2  ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_2.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_3&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_3  ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_3.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
		else if(v==et_nextdate_4&&hasFocus){
			mPopupWindow = new MyPopupWindow(getContext());			
			mPopupWindow.showAtLocation(v.findViewById(R.id.et_tc_nextdate_4  ), Gravity.CENTER, 0, 0);

			Button btn=mPopupWindow.getButton();
			btn.setOnClickListener(new OnClickListener(){

				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					et_nextdate_4.setText(mPopupWindow.getDate());
					mPopupWindow.dismiss();
				}
				
			});
		}
	}
}
